package controller;

import java.util.Date;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.persistence.EntityManager;

import model.Checklist;
import persistence.JPAUtil;


@ManagedBean
@ViewScoped
public class ChecklistBean {
	
	private Checklist checklist;
	private Date hoje;
	
	@PostConstruct
	public void init(){
		hoje =  new Date();
		checklist = new Checklist();
		checklist.setData(hoje);
	}
	
	public void salvar(){
		EntityManager em = JPAUtil.getEntityManager();
		em.getTransaction().begin();
		em.persist(checklist);
		em.getTransaction().commit();
		em.close();
		checklist = new Checklist();
	}

	public Checklist getChecklist() {
		return checklist;
	}

	public void setChecklist(Checklist checklist) {
		this.checklist = checklist;
	}

	public Date getHoje() {
		return hoje;
	}

	public void setHoje(Date hoje) {
		this.hoje = hoje;
	}	
	
	
	
}
